<template>
  <v-app id="app" class="rootApplication">
    <progress-linear class="appProgress"></progress-linear>

    <router-view v-if="langChangeShow"></router-view>

    <snackbar-list class="snackbarList"></snackbar-list>
  </v-app>
</template>

<script>
// 路由跳转进度条组件
import ProgressLinear from './components/ProgressLinear/ProgressLinear.vue'
// 提示框组件
import SnackbarList from './components/Snackbar/SnackbarList.vue'

import { mapGetters } from 'vuex'
import { addDynamicRoutes } from './router/permission'
import { getSessionItem } from './utils/token'
import { ACCESS_TOKEN } from './variables/storageVariables'

export default {
  name: 'App',

  components: {
    SnackbarList,
    ProgressLinear
  },

  data() {
    return {
      langChangeShow: true,
      updateView: true
    }
  },

  computed: {
    ...mapGetters(['snackbars', 'lang'])
  },

  watch: {
    // snackbars(nv) {
    //   console.log('snackbarchange')
    //   this.clearSnackbars()
    // }

    lang() {
      // this.langChangeShow = false
      // this.$nextTick(() => {
      //   this.langChangeShow = true
      // })
    }
  },

  created() {
    this.$store.dispatch('screen/getEquipmentInfo')
  },

  mounted() {
    window.onresize = () => {
      return (() => {
        this.$store.dispatch('screen/getEquipmentInfo')
      })()
    }
    /*  const hasToken = getSessionItem(ACCESS_TOKEN)
    if (hasToken) {
      addDynamicRoutes()
    } */
  },

  methods: {
    clearSnackbars() {
      this.$store.commit('snackbar/CLEAR_SNACKBARS')
      // setTimeout(() => {
      // }, 3000)
    }
  }
}
</script>

<style lang="scss" scoped>
.appProgress {
  // 进度条定位
  position: absolute;
  top: 0px;
}

.rootApplication {
  position: relative;
  .snackbarList {
    position: absolute;
    top: 0;
  }
}
</style>
